<template>
	<view>
		<cu-custom bgColor="bg-gradual-blue" :isBack="true">
			<block slot="content">
				{{title}}
			</block>
		</cu-custom>
		<view style="height: 40px;">
			<a-tabs :index="weekIndex" style="position: fixed;left: 0;right: 0;z-index: 2;font-size: 12px;" :row="7" type="border"
			 :value="week"></a-tabs>
		</view>
		<a-grid :list="list" :cell="3" :closeHeight="true">
			<template #default="{row,index}">
				<view style="text-align: center;line-height: 1.6em;margin: 10px 0;">
					<view>{{row.title}}</view>
					<view>{{row.name}}</view>
					<view style="color:#7A7A7A;font-size: 12px;">{{row.time}}</view>
				</view>
			</template>
		</a-grid>
		<view style="color: red;">
			按星期查询参数字段没有？
			<br>
			建议加上显示 - 任课老师及学科字段
		</view>
		
	</view>
</template>

<script>
	import {
		getMonthWeek
	} from "@/common/js/utils";
	export default {
		data() {
			return {
				title: "",
				week: ['日','一', '二', '三', '四', '五', '六'].map(x => {
					return {
						name: '星期' + x
					}
				}),
				weekIndex: -1,
				list:[]
			}
		},
		created() {
			const date = new Date();
			this.weekIndex = date.getDay();
			const {
				getYear,
				getMonth,
				getWeek
			} = getMonthWeek(date.getFullYear(), date.getMonth() + 1, date.getDate());
			this.title = `${getYear}年${getMonth}月 第${getWeek}周`
			
			this.$http.get('/api/v1/course/selectMyCourses').then(res=>{
				this.list = (res || []).map(x=>{
					x = x.classHour;
					return {
						title: x.classHourName,
						name: "",
						time: x.classHourTime
					}
				});
			});
		},
		methods: {
			
		}
	}
</script>

<style scoped>
	page {
		background-color: #fff;
	}
</style>
